package it.tukano.fun;

import java.util.Collection;

/**
 * Given a collection, returns true if it contains some element
 * @author pgi
 * @param <A> 
 */
public class Contains<A> implements Function1<A, Boolean> {

    private final Collection<? extends A> set;

    /**
     * Initializes this function
     * @param set the collection to check
     */
    public Contains(Collection<? extends A> set) {
        this.set = set;
    }

    /**
     * Returns true if the collection contains the given element
     * @param p the element to find
     * @return true if the collection passed to the constructor contains the element
     */
    public Boolean apply(A p) {
        return set.contains(p);
    }
}
